Skip to content

Add log library based on log4p#118

Closed
ngeiswei wants to merge 9 commits intotrueagi-io:mainfrom
ngeiswei:log-library
Closed

Add log library based on log4p#118
ngeiswei wants to merge 9 commits intotrueagi-io:mainfrom
ngeiswei:log-library

Conversation

@ngeiswei
Copy link
Contributor

@ngeiswei ngeiswei commented Feb 2, 2026

Here is a complete, albeit slow, library for PeTTa to log timestamped messages into a file.

I qualify it as complete because it has everything that I need but of course more can always be added. It is slow, in particular logging a message actually opens the log file, writes the message, then closes it. So only use this logger for sufficiently infrequent logging tasks, for the time being anyway. This is of course intended to be fixed in the future.

A couple of remarks:

  1. One may need to run the command swipl pack install log4p to install log4p. It is unclear to me how to install this automatically. Maybe the build script of PeTTa could take care of it. I am not sure.
  2. I am not sure what method naming convention to follow. I have prefixed all methods by logger-. Examples of method names are logger-filepath, logger-info, etc. Another naming convention could be to prefix method names with Logger. which would create method names Logger.filepath, Logger.info, etc. Or maybe the Prolog way, logger:filepath, logger:info, etc. I don't know which way we should go for, so please let me know if you do.

@ngeiswei
Copy link
Contributor Author

ngeiswei commented Feb 2, 2026

BTW, if my Prolog writing style does not follow whatever current writing style is being followed, please let me know. Or if my Prolog code needs idiomatic corrections. I am still a novice Prolog programmer.

@ngeiswei
Copy link
Contributor Author

ngeiswei commented Feb 2, 2026

Fix for #116

@pisaev1
Copy link
Collaborator

pisaev1 commented Feb 6, 2026

Looks Good

Copy link
Collaborator

@pisaev1 pisaev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks Good

Copy link
Collaborator

@pisaev1 pisaev1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I think it should go to a separate repo.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I think it should go to a separate repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fact that it potentially requires an installation step from the user

swipl pack install log4p

makes me want to agree. I suppose, only if this installation is handled automatically or added to build.sh or such, can it be part of the standard library, otherwise it is probably better hosted on its own repo.

I am neutral on this. So just provide some final confirmation and I will move it to its own repo.

Copy link
Collaborator

@patham9 patham9 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can upload your library to a repository petta_lib_logger (name convention for PeTTa libs), the way it works: lib_logger.pl, lib_logger.metta and logger_example.metta are in the root of the repository. Then you can import your library with the log4p installation step included: !(git-import! "https://github.com/ngeiswei/petta_lib_logger" "swipl pack install log4p")
Last: please also add it to the registry page: https://github.com/trueagi-io/PeTTa/wiki/Extension-libraries

Copy link
Contributor Author

@ngeiswei ngeiswei Feb 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have moved it to its own repo, however it fails to pass the tests in logger_example.metta. Any idea?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@ngeiswei ngeiswei Feb 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @patham9. I've added petta_lib_logger to Extension-libraries, note that I took the freedom to reformat the page a bit (use markdown lists + added some more hyper-links). Let me know if you wish the formatting to be different.

@ngeiswei
Copy link
Contributor Author

Closing as it has been moved to its own repo.

@ngeiswei ngeiswei closed this Feb 16, 2026
@ngeiswei ngeiswei deleted the log-library branch February 19, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants